<?php

/**
 * Generates links with the primary key(s) for Crud actions
 *
 * @author    Mon Zafra <monzee at gmail>
 * @copyright (c)2009 Mon Zafra
 * @license   http://mz-project.googlecode.com/svn/trunk/LICENSE    MIT License
 * @version   SVN: $Id: PkLink.php 12 2009-02-28 13:39:31Z monzee $
 */
class Crud_PkLink extends Zend_View_Helper_Abstract
{
    /**
     * generate link with primary key(s)
     *
     * @param array  $pkeys  Array of primary keys
     * @param array  $values The tuple
     * @param string $action Action to call
     * @return string
     */
    public function pkLink($pkeys, $values, $action)
    {
        $url = array('action' => $action, 'sort' => null, 'order' => null, 'page' => null);
        foreach ($pkeys as $pk) {
            $url[urlencode($pk)] = urlencode($values[$pk]);
        }
        return $this->view->url($url);
    }

}
